package com.puzzud.engine.video;

import com.puzzud.engine.video.VideoObject;

// VideoObject2D
public abstract class VideoObject2D extends VideoObject
{
	protected int xPosition;
	protected int yPosition;
	
	protected int width;
	protected int height;
	
	protected boolean isVideoObjectScaled;
	protected float xScale;
	protected float yScale;

        protected int scaleType;

        public final static int SCALE_TYPE_EXACT            = 0;
        public final static int SCALE_TYPE_SMOOTH           = 1;
        public final static int SCALE_TYPE_REALLY_SMOOTH    = 2;
	
	public VideoObject2D()
	{
		setPosition( 0, 0 );

                setScaleType( SCALE_TYPE_EXACT );
	}
	
	public VideoObject2D( int width, int height )
	{
            // TODO These arguments need to actually mean/do something.
            setPosition( 0, 0 );

            setScaleType( SCALE_TYPE_EXACT );
	}
	
	public void setXPosition( int xp )
	{
		xPosition = xp;
	}
	
	public void setYPosition( int yp )
	{
		yPosition = yp;
	}
	
	public void setPosition( int xp, int yp )
	{
		setXPosition( xp );
		setYPosition( yp );
	}
	
	protected abstract void setRealDimensions( int width, int height );
	
	public void setDimensions( int width, int height )
	{
		this.width = width;
		this.height = height;
		
		if( ( getRealWidth() == width ) && ( getRealHeight() == height ) )
		{
			setScale( false );
			xScale = 1.0f;
			yScale = 1.0f;
		}
		else
		{
			setScale( true );
			
			if( getRealWidth() == 0 )
			{
				xScale = 0;
			}
			else
			{
				xScale = ( ( float )width / ( float )getRealWidth() );
			}
			
			if( getRealHeight() == 0 )
			{
				yScale = 0;
			}
			else
			{
				yScale = ( ( float )height / ( float )getRealHeight() );
			}
		}
	}
	
	public int getXPosition()
	{
		return( xPosition );
	}
	
	public int getYPosition()
	{
		return( yPosition );
	}
	
	public int getWidth()
	{
		return( width );
	}
	
	public int getHeight()
	{
		return( height );
	}
	
	abstract int getRealWidth();
	abstract int getRealHeight();
	
	public void setScale( boolean s )
	{
		isVideoObjectScaled = s;
	}
	
	public boolean isScaled()
	{
		return( isVideoObjectScaled );
	}
	
	public double getXScale()
	{
		return( xScale );
	}
	
	public double getYScale()
	{
		return( yScale );
	}

        public int getScaleType()
        {
            return( scaleType );
        }

        public void setScaleType( int scaleType )
        {
            this.scaleType = scaleType;
        }

	// NOTE Do I have to override this here?
	public void draw( VideoObject videoObject )
	{

        }
}
